var iw_homethailand = new google.maps.InfoWindow();
function HomeThailand(values) {
    $.ajax({
        type: "GET",
        url: "ajax/homethailand.php",
        data: {values: values},
        dataType: "xml",
        success: function (xml) {
            console.log(xml);
            $(xml).find("marker").each(function () {
                var name = $(this).find("name").text();
                var latitude = $(this).find("latitude").text();
                var longitude = $(this).find("longitude").text();
                var pic = $(this).find("pic").text();
                //console.log("name", name, " ", "latitude", latitude, " ", "longitude", longitude, " ", "pic", pic);
                if (values == "Condo")
                    images = "image/images/color_icons_blue_condo.png";
                else if (values == "Townhouse")
                    images = "image/images/color_icons_pink_townhouse.png";
                else if (values == "SingleHouse")
                    images = "image/images/color_icons_green_home.png";

                var latlng = new google.maps.LatLng(latitude, longitude);
                var Sreach = new google.maps.Marker({
                    map: map,
                    position: latlng,
                    icon: images
                });
                //console.log("name = ", name);
                if (values == "Condo")
                    Condo.push(Sreach);
                if (values == "SingleHouse")
                    SingleHouse.push(Sreach);
                if (values == "Townhouse")
                    Townhouse.push(Sreach);

                google.maps.event.addListener(Sreach, 'click', function () {
                    if (iw_homethailand)
                        iw_homethailand.close();
                    var content = "<table class='homethailand' style='width:150pt;'><tr><td>โครงการ" + name + "</td></tr></table>";
                    iw_homethailand = new google.maps.InfoWindow({
                        content: content,
                        position: latlng,
                        maxWidth: 3000,
                        maxHeight: 2500
                    });
                    iw_homethailand.open(map, this);
                });
            });
        }
    });
}